# Maintainer: Wireshark Core Team <wireshark-dev@wireshark.org>

_realname=sbc
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.0
pkgrel=1
pkgdesc="Bluetooth Subband Codec (SBC) library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='http://www.bluez.org'
license=('spdx:GPL-2.0-or-later OR LGPL-2.1-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://mirrors.edge.kernel.org/pub/linux/bluetooth/${_realname}-${pkgver}.tar.gz"
        "0001-include-stdint-h.patch"
        "0002-no-symbol-version.patch")
sha256sums=('897c1463fc6ad25a7822dfa2ce53c340c4ac8054eab381f72aa7d3bf16517738'
            'e4960a21717a068e33452bec96cdd7626939dc0a6455a7035d4de7dfe72e7948'
            '9caa7880b5bf2d05ea106f72f7dad7fe73ba41c0ca9a459360323ada1e35a415')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  patch -p1 -i "${srcdir}/0001-include-stdint-h.patch"
  patch -p1 -i "${srcdir}/0002-no-symbol-version.patch"
  autoreconf -fvi
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../"${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --host="${MINGW_CHOST}" \
    --target="${MINGW_CHOST}" \
    --enable-static \
    --enable-shared \
    --disable-tester \
    --disable-tools

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.LIB" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
